package com.hwadee.teachingprocessmanagementsystem.service.base.impl;

import com.hwadee.teachingprocessmanagementsystem.entity.Campus;
import com.hwadee.teachingprocessmanagementsystem.dao.CampusDao;
import com.hwadee.teachingprocessmanagementsystem.service.base.CampusService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import jakarta.annotation.Resource;

import java.util.List;

/**
 * (Campus)表服务实现类
 *
 * @author makejava
 * @since 2024-07-11 14:20:02
 */
@Service("campusService")
public class CampusServiceImpl implements CampusService {
    @Resource
    private CampusDao campusDao;

    /**
     * 通过ID查询单条数据
     *
     * @param campusId 主键
     * @return 实例对象
     */
    @Override
    public Campus queryById(Integer campusId) {
        return this.campusDao.queryById(campusId);
    }


    /**
     * 新增数据
     *
     * @param campus 实例对象
     * @return 实例对象
     */
    @Override
    public Campus insert(Campus campus) {
        this.campusDao.insert(campus);
        return campus;
    }

    /**
     * 修改数据
     *
     * @param campus 实例对象
     * @return 实例对象
     */
    @Override
    public Campus update(Campus campus) {
        this.campusDao.update(campus);
        return this.queryById(campus.getCampusId());
    }

    /**
     * 通过主键删除数据
     *
     * @param campusId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer campusId) {
        return this.campusDao.deleteById(campusId) > 0;
    }

    @Override
    public List<Campus> queryAllByLimit(Campus campus) {
        return this.campusDao.queryAllByLimit(campus);
    }
}
